home *** CD-ROM | disk | FTP | other *** search
GW-BASIC | 1984-06-13 | 8.6 KB | 245 lines |
- 100 DIM LW(6) , HI(6)
- 200 FAC =46500 : CTY$="Los Angeles" : SRB$="Chatsworth"
- 300 ' cty$ is the harbor city (you may alter this)
- 400 ' srb$ is a suburb of the harbor city. These names are used in messages.
- 500 ' The users name influences how the game proceedes. See the subroutine
- 600 ' which evaluates the name at about line 19800.
- 700 '
- 800 '
- 900 LW(1)=21:LW(2)=19 : LW(3)=15 : LW(4)=10 : LW(5)=6 : LW(6)=4
- 1000 'LW(1)=19:LW(2)=15 : LW(3)=12 : LW(4)= 9 : LW(5)=6 : LW(6)=4
- 1100 HI(1)=18:HI(2)=14 : HI(3)=11 : HI(4)= 7 : HI(5)=5 : HI(6)=3
- 1200 'HI(1)=16:HI(2)=13 : HI(3)=10 : HI(4)= 7 : HI(5)=5 : HI(6)=3
- 1300 LINE INPUT"What is your name? ";PNAME$
- 1400 IF LEN(PNAME$)=0 THEN GOTO 1300
- 1500 LET Z=RND : LET GMS=0 : LET TS=0
- 1600 C=ASC(MID$(PNAME$,1,1))
- 1700 IF C>96 AND C<123 THEN MID$(PNAME$,1,1)=CHR$(C-32)
- 1800 GOSUB 19800
- 1900 DIM LN$(80),SH(80)
- 2000 RANDOMIZE TIMER
- 2100 PRINT "do you want instructions "PNAME$ " (y or n)"; :INPUT Q$
- 2200 IF Q$="n" THEN 4200
- 2300 CLS : PRINT "You are in control of a":COLOR 0,7
- 2400 LOCATE 1,25:PRINT CTY$ : COLOR 7,0
- 2500 PRINT "coastal defense cannon battery. You are trying to sink approching"
- 2600 PRINT "warships. A hit within" : COLOR 0,7 :LOCATE 3,25 :PRINT RNG
- 2700 COLOR 7,0 : LOCATE 3,31 : PRINT "yards will do it."
- 2800 PRINT "For more range : elevate (toward 45 degrees)."
- 2900 PRINT "If you overshoot : change the elevation away from 45 degrees."
- 3000 PRINT "If you allow the ships to move they will advance toward your"
- 3100 PRINT "harbor. If you allow one to dock, you lose. The ships move as"
- 3200 PRINT "time passes, thus if you shoot faster, the targets move less."
- 3300 PRINT "Entries are in degrees example: 2.5 is two and one half degrees. "
- 3400 PRINT "Some of the ships are submarines. They remain below the water most
- 3500 PRINT "of the time. Part of the time you may see their periscope. Watch"
- 3600 PRINT "for the subs. When the subs are below water you will not see them.
- 3700 PRINT "When a ship is above water you will see 's'. When more than one"
- 3800 PRINT "one ship is in one location you will see the number of ships in "
- 3900 PRINT "that spot. Some of the ships may on occasion try to shoot at your"
- 4000 PRINT "missle with an anti-missle. If they hit your missle, then it never"
- 4100 PRINT "hits the water, and the attacking ships are safe for that turn. "
- 4200 PRINT "OK, LET'S GET STARTED" : LET STP=0
- 4300 ' sp% is # of ships, rng is how close the shot must come to be a hit
- 4400 ' inc is how fast the speed of the ships increases
- 4500 ' stp is the first step in speed
- 4600 IF CLSS=1 THEN LET SP% = 6 : LET RNG=90
- 4700 IF CLSS=2 THEN LET SP% = 3 : LET RNG=100
- 4800 IF CLSS=3 THEN LET SP% = 3 : LET RNG=150
- 4900 PRINT "Do you want the target ship to move between shots?"
- 5000 PRINT "(y or n)" ; : INPUT Q$
- 5100 IF Q$ <> "y" AND Q$ <> "n" GOTO 4900
- 5200 IF Q$ ="n" AND CLSS <>1 THEN STP=0 : GOTO 6300
- 5300 IF Q$ ="n" AND CLSS = 1 GOTO 5600
- 5400 ' q$ must =y if we fall through
- 5500 LET STP=90 : GOTO 6300
- 5600 CLS : PRINT "Now look " PNAME$ ", being a person of your"
- 5700 PRINT "stature and skill level, I can not allow you to take the easy"
- 5800 PRINT "way to play this game. I will force the ships to move. As a "
- 5900 PRINT "penalty for trying to play this game the easy way I will not"
- 6000 LET SP%=6 : LET INC=1.5 :LET RNG=80 : STP=90
- 6100 PRINT "score a hit for YOU unless you are within" :COLOR 0,7
- 6200 LOCATE 5,43 : PRINT RNG :COLOR 7,0 : LOCATE 5,46: PRINT " yards!"
- 6300 IF STP< 140 GOTO 6500
- 6400 LET SP%=SP% + 1 : STP=90
- 6500 LET STP=STP * 1.1
- 6600 PRINT "The maximum speed of the advancing ships is" STP/20 "knots."
- 6700 PRINT "distance to the ships are:"
- 6800 FOR I = 1 TO SP% : SH(I)=8000-5000*RND(1)
- 6900 PRINT " " SH(I) " yards " : NEXT I
- 7000 FOR K=1 TO SP%-1
- 7100 FOR I=1 TO SP%-1
- 7200 IF SH(I) > SH(I+1) THEN SWAP SH(I),SH(I+1)
- 7300 NEXT I
- 7400 NEXT K
- 7500 LET H=0
- 7600 REM "h=hits , s=shots this game , ts=total shots, gms=games "
- 7700 LET S=0 : LTM=TIMER : STM=LTM
- 7800 PRINT " " : PRINT "elevation" ;
- 7900 INPUT E
- 8000 CTM=TIMER : IVL=CTM - LTM : LTM=CTM
- 8100 LET S=S+1
- 8200 IF (E > 0.4 ) AND ( E < 88) THEN 10800
- 8300 IF (E < -2 ) OR (E > 92) THEN 9700
- 8400 IF E <> 90 THEN 8700
- 8500 PRINT "you shot STRAIGHT up...."
- 8600 GOTO 8800
- 8700 PRINT " you shot nearly straight up..."
- 8800 PRINT "Lets get out of here!" : JJ=40
- 8900 FOR I = 1 TO 10 : FOR J=1 TO 10 : JJ=JJ+1 : SOUND JJ,1 : NEXT J
- 9000 PRINT TAB(15) "." : NEXT I
- 9100 SOUND 40,40 : COLOR 0,7
- 9200 PRINT TAB(13) "boom! "
- 9300 COLOR 7,0
- 9400 PLAY "l10 o1abcdef l32 o1abcdefabcdef"
- 9500 PRINT
- 9600 GOTO 7800
- 9700 PRINT "The mayor of " CTY$ " should enjoy that one."
- 9800 PRINT "That round may hit " SRB$ "!"
- 9900 LET C=1
- 10000 GOTO 9500
- 10100 COLOR 0,7:PRINT TAB(3) "NEWS FLASH!" : COLOR 7,0
- 10200 PRINT SRB$ " house hit by MYSTERY MISSLE"
- 10300 PLAY "t60 o4aaaaaaaaaaaaa t120" : CLS
- 10400 LET C=0
- 10500 RETURN
- 10600 PRINT "ILLEGAL VALUE. Try again."
- 10700 GOTO 9500
- 10800 CLS
- 10900 IF C <> 1 THEN 11100
- 11000 GOSUB 10100
- 11100 IF E < 0.5 THEN 10600
- 11200 LET E2=2*E/57.2958
- 11300 REM "j is where the shot landed"
- 11400 LET J =FAC * SIN(E2)
- 11500 GOSUB 14000
- 11600 IF H < SP% GOTO 7800
- 11700 REM "if we fall through then we hit all the ships"
- 11800 LET TS=TS + S
- 11900 LET GMS=GMS + 1
- 12000 PLAY "l32 o6abcdef abcdef abcdef abcdef abcdef"
- 12100 IF S< 20 THEN 12300
- 12200 PRINT " ***** finally ******"
- 12300 TS%=TIMER - STM
- 12400 MN%=TS% / 60 : SC%= TS% MOD 60
- 12500 PRINT S "rounds fired in " MN% " minutes" SC% " seconds"
- 12600 IF TS / GMS < SP% * 3 THEN LET INC = INC * 1.2
- 12700 IF STP <>0 GOTO 13300
- 12800 IF GMS > 4 GOTO 13100
- 12900 IF TS / GMS > 9 GOTO 13300
- 13000 PRINT "You are TOO good."
- 13100 PRINT "I am going to allow the ship to move between shots."
- 13200 LET STP=100
- 13300 PRINT "Another game " PNAME$" (y or n)";
- 13400 INPUT Q$
- 13500 IF Q$ = "y" THEN 6300
- 13600 IF Q$ <> "n" THEN 13300
- 13700 PRINT "ending now"
- 13800 PRINT "You played"GMS" games, and you took an average of"TS/GMS" shots."
- 13900 SYSTEM
- 14000 REM "FILL IN THE STATUS LINE WITH ALL DOTS"
- 14100 LOCATE 13,1
- 14200 FOR K=1 TO 80 : LN$(K) ="." : NEXT K
- 14300 LET S%=(J / 100) : IF S% > 80 THEN LET S% = 81
- 14400 ' ln is the line on the screen that the shot is placed
- 14500 ' s% - w is the column on the screen that the shot is placed
- 14600 W%=31 : LN%= 0 : SHT$="n"
- 14700 FOR X%=1 TO 4 : Z% = 5 - X%
- 14800 FOR Y%=1 TO 3 : W%= W% - Z% : LN%=LN%+ 1
- 14900 IF S% > W% THEN GOSUB 21300
- 15000 NEXT Y%
- 15100 NEXT X%
- 15200 LOCATE 13,1
- 15300 FOR I=1 TO SP%
- 15400 SB= I MOD 3
- 15500 IF SH(I) = 0 GOTO 17400
- 15600 TMF = (1 + ((IVL -8 ) / 8 ))
- 15700 LET MV= (STP * (2 * (RND(1) -1 ) ) )
- 15800 LET SH(I)=SH(I) + (MV + (MV * TMF)) / 2
- 15900 IF SH(I) > 100 GOTO 16500
- 16000 LOCATE 17,1
- 16100 PRINT "The enemy ship landed at your harbor. You lose."
- 16200 LET I=SP%
- 16300 LET H=I
- 16400 GOTO 17400
- 16500 LET N=SH(I)-J
- 16600 LET D=INT(N)
- 16700 IF ABS(D) > RNG THEN 17400
- 16800 REM "if we branch then we missed ship(i) "
- 16900 REM "if we fall through, then we hit one "
- 17000 LOCATE 14+I,I : PRINT "GOT 'EM"
- 17100 LET SH(I)=0
- 17200 PLAY "l32 o2abcdef abcdef abcdef abcdef abcdef"
- 17300 LET H=H+1
- 17400 LET II% = SH(I)/100
- 17500 ' every 1 ST ship is a sub
- 17600 IF SB <> 1 GOTO 18000
- 17700 ' show only the periscope once out of 4
- 17800 IF S MOD 4 <>2 GOTO 18400
- 17900 IF LN$(II%)="." THEN LET LN$(II%)="|" : GOTO 18400
- 18000 IF LN$(II%)="3" THEN LET LN$(II%)="4"
- 18100 IF LN$(II%)="2" THEN LET LN$(II%)="3"
- 18200 IF LN$(II%)="s" THEN LET LN$(II%)="2"
- 18300 IF LN$(II%)="." THEN LET LN$(II%)="s"
- 18400 NEXT I
- 18500 LOCATE 13,1
- 18600 ' BYPASS IF SHOT HIT
- 18700 LET S%=J/100 : IF S% < 81 THEN 19000
- 18800 LET LN$(80)=">" : LET S%=80 : GOTO 19100
- 18900 IF J=0 THEN GOTO 19100
- 19000 LET LN$(S%)="*"
- 19100 FOR K=1 TO 80 : PRINT LN$(K) ; : NEXT K
- 19200 FOR I= 1 TO S% - 1
- 19300 IF SH(I) <> 0 THEN GOTO 19500
- 19400 SH(I) = SH(I+1) : SH (I+1)= 0
- 19500 NEXT I
- 19600 'put ships not hit to the front
- 19700 RETURN
- 19800 '******* Evaluate the name ******
- 19900 ' class 1 users have it hard.
- 20000 ' class 3 users have it easy.
- 20100 ' everyone else is in the middle.
- 20200 '
- 20300 ' Before the evaluation is done the first character of the name was
- 20400 ' forced to be upper case.
- 20500 ' The first three characters of the name are used in the evaluation.
- 20600 LET F$=MID$(PNAME$,1,3)
- 20650 ' names begining with the following characters have it tough.
- 20700 IF (F$="Mar" ) OR (F$="Ger" ) OR (F$="Mr." ) THEN RNG=90:CLSS=1:RETURN
- 20750 ' names begining with the following characters have it easy.
- 20800 IF (F$="Kat" ) OR (F$="Lee" ) THEN RNG=110:CLSS=3:RETURN
- 20900 ' class 2 player setup
- 21000 LET RNG=100: LET CLSS=2 :RETURN
- 21100 ' ANTI SHOT SUBROUTINE
- 21200 Q%= (J - SH(1) ) / 100
- 21300 LOCATE LN%,S%-W% : PRINT "." : SOUND 2000-(LN%*100),2
- 21400 IF LN% > 6 THEN GOTO 21900
- 21500 IF SHT$ = "y" THEN GOTO 21600
- 21600 Q%= (J - SH(1) ) / 100
- 21700 IF (Q% > LW(LN%) ) OR (Q% < HI(LN%) ) THEN GOTO 21900
- 21800 SHT$="y" : SHL%=13 : SHC%=(SH(1) / 100)
- 21900 IF SHT$="n" THEN GOTO 24200
- 22000 SHL%=SHL% - 1 : SHC%=SHC% + 1
- 22100 'LOCATE LN%+10,1
- 22200 'PRINT LN% SHL% SHC% S%-W% S% W%
- 22300 IF SHC% > 80 THEN GOTO 24200
- 22400 LOCATE SHL%,SHC% : PRINT "/"
- 22500 IF (SHL% < LN%) GOTO 24200
- 22600 IF (SHC% +1< S%-W%+Z%)AND (SHL% =LN% ) THEN GOTO 22700 ELSE GOTO 24200
- 22700 ' else hit shot with anti shot
- 22800 LOCATE SHL%,SHC%-2 : PRINT " * " : PLAY "l64 o6abcdef abcdef "
- 22900 LOCATE SHL%-1,SHC%-2 : PRINT " *** "
- 23000 LOCATE SHL%+1,SHC%-2 : PRINT " *** " : PLAY "l64 o6abcdef abcdef "
- 23100 COLOR 0,7
- 23200 LOCATE SHL%-1,SHC%-1 : PRINT " "
- 23300 LOCATE SHL%+1,SHC%-1 : PRINT " "
- 23400 LOCATE SHL%,SHC%-2 : PRINT " " : PLAY "l64 o6abcdef abcdef "
- 23500 LOCATE SHL%-1,SHC%-2 : PRINT "*******"
- 23600 LOCATE SHL%,SHC%-2 : PRINT "*******" : PLAY "l64 o6abcdef abcdef "
- 23700 LOCATE SHL%,SHC%-2 : PRINT " "
- 23800 LOCATE SHL%-1,SHC%-2 : PRINT " "
- 23900 LOCATE SHL%+1,SHC%-2 : PRINT " " : PLAY "l64 o6abcdef abcdef "
- 24000 X%=4 : Y%=3 :J=0
- 24100 COLOR 7,0
- 24200 RETURN
-